package com.gzy.rpsm_property.utils;

public class StringUtil {
    public static int getNumberFromString(String str) {
        char[] chars = str.toCharArray();
        StringBuilder builder = new StringBuilder();
        for (char c : chars) {
            if (c >= '0' && c <= '9') {
                builder.append(c);
            }
        }
        return Integer.valueOf(builder.toString());
    }
   public static String numberToLen2String(int i){
        if(-1 < i && i < 10){
            return "0" + i;
        }else{
            return i+"";
        }
    }
    public static Integer stringPriceToInt(String price) throws Exception{
        if(price != null){
            try{
                Double d = Double.valueOf(price);
                return Double.valueOf(d * 100).intValue();
            }catch (NumberFormatException e){
                throw new Exception("不是浮点数格式");
            }
        }
        return null;
    }
}
